<br/>
 <script>
    $(function() {
    $( "#date" ).datepicker({
    changeMonth: true,
    changeYear: true,
    monthNames:true,
    dateFormat:'dd/mm/yy'
    });
    });
</script>
<script type='text/javascript'>
    function creatyear() {
        var date=document.getElementById("date").value;
        var year=date.substr(6);
        document.getElementById("year").value=year;
    }
</script>
 <style>
    span.label2{display:block;float:left;width:170px}
 </style>
 <article id="container">
        <section id="top_regis" class="wrapper">
            <div class="top_tep1 clearfix">
                  <div class="info_regis">
                    <h2 class="tt_regis1">Đăng kí gia sư</h2>
                    <p class="name">Xin chào: <?php if($this->session->userdata('id')){$user=$this->common_model->getone('users',array('id'=>$this->session->userdata('id'))); echo $user->name;}?></p>
                    <p class="user_regis">Tên đăng nhập của bạn : <b><?php echo $user->email;?></b></p>
                    </div>
                    <!-- /.info_regis -->
                    <div class="step_info">
                    <p class="info_step">Thông tin cá nhân | <span>2 của 4 bước hoàn thành</span></p>
                    <p class="percent_step"><span style="width:50%;">percent</span></p>
                  </div>
                  <!-- /.step -->
            </div>
            <?php $this->load->view('mod_account/views_step.php'); ?>
        </section>
        <section class="wrapper thongtinus" style="padding-bottom: 100px;">
            <form action="<?php echo base_url();?>dang-ky/buoc2" method="post" enctype="multipart/form-data">
                <input type="hidden" name="year" id="year" value=" " />
                <p class="row-b3"><span class="label2">Giới tính</span>
					<select name="gender">
						<option value="1" <?php if($this->session->userdata('gender') == 1) echo 'selected';?>>Nam</option>
						<option value="0" <?php if($this->session->userdata('gender') == 0) echo 'selected';?>>Nữ</option>
					</select>
				</p>
                <p class="row-b3"><span class="label2">Ngày sinh</span><input type="text" id="date" onkeyup="creatyear();" value="<?php if($this->session->userdata('birthday')){echo $this->session->userdata('birthday');}elseif(!empty($_POST['birthday'])){echo $_POST['birthday'];}else{echo $user->birthday;}?>" name="birthday" size="50" /><?php echo form_error('ngaysinh');?></p>
                <p class="row-b3" style="color:#7DB520;font-size:15px;font-weight:bold">Trinh độ học vấn </p>
                <p class="row-b3"><span class="label2">Trường Cấp 3 </span> <input type="text" name="cap3" size="50" value="<?php if($this->session->userdata('cap3')){echo $this->session->userdata('cap3');}elseif(!empty($_POST['cap3'])){echo $_POST['cap3'];}else{echo $user->cap3;}?>" /><?php echo form_error('cap3');?></p>
                <p class="row-b3"><span class="label2">Trường đại học (Cao Đẳng)</span> <input type="text" name="bang1" size="50" value="<?php if($this->session->userdata('bang1')){echo $this->session->userdata('bang1');}elseif(!empty($_POST['bang1'])){echo $_POST['bang1'];}else{echo $user->bang1;}?>" /><?php echo form_error('bang1');?></p>
                <p class="row-b3"><span class="label2">Chuyên nghành </span><input type="text" name="chuyennganh" size="50" value="<?php if($this->session->userdata('chuyennganh')){echo $this->session->userdata('chuyennganh');}elseif(!empty($_POST['chuyennganh'])){echo $_POST['chuyennganh'];}else{echo $user->chuyennganh;}?>" /><?php echo form_error('chuyennganh');?></p>
                <p class="row-b3"><span class="label2">Nghề nghiệp</span> <input type="text" size="50" name="jobs" value="<?php if($this->session->userdata('jobs')){echo $this->session->userdata('jobs');}elseif(!empty($_POST['jobs'])){echo $_POST['jobs'];}else{echo $user->jobs;}?>" /></p> 
                      
                <p class="row-b3"  style="color:#7DB520;font-size:15px;font-weight:bold">Mức lương</p>
                <p class="row-b3"><span class="label2">Mức lương</span> <input type="text" name="mucluong" size="40" value="<?php if($this->session->userdata('mucluong')){echo $this->session->userdata('mucluong');}elseif(!empty($_POST['mucluong'])){echo $_POST['mucluong'];}else{echo $user->mucluong;}?>" /> /(1 buổi)<?php echo form_error('mucluong');?></p>
                <p class="row-b3"  style="color:#7DB520;font-size:15px;font-weight:bold">Địa chỉ liên lạc</p>
                <p class="row-b3"><span class="label2">Địa chỉ nhà </span><input type="text" name="address" size="50" value="<?php if($this->session->userdata('address')){echo $this->session->userdata('address');}elseif(!empty($_POST['address'])){echo $_POST['address'];}else{echo $user->address;}?>" /><?php echo form_error('address');?></p>
                <p class="row-b3"><span class="label2">Quận - Thành phố</span> <label>
                                    <select id="province" class="rq_select" name="city">
                                        <option>Tỉnh - Thành phố</option>
                                        <?php if(!empty($tp)){
                                            foreach($tp as $tp){
												if($this->session->userdata('city') == $tp->id){
                                                	echo '<option selected value="'.$tp->id.'">'.$tp->title.'</option>';
                                                } else {
                                                	echo '<option value="'.$tp->id.'">'.$tp->title.'</option>';
                                                }
                                            }
                                        }?>
                                    </select>
                                </label>
                                <label>
                                    <select id="district" class="rq_select" name="district">
                                        <option value="">-- Quận Huyện --</option>
                                    </select>
                                </label></p>
                <p class="row-b3"><span class="label2">Điện thoại</span> <input value="<?php if($this->session->userdata('phone')){echo $this->session->userdata('phone');}elseif(!empty($_POST['phone'])){echo $_POST['phone'];}else{echo $user->phone;}?>" size="50" type="text" name="phone" /><?php echo form_error('phone');?></p>
                <p class="row-b3"><span class="label2">Thời gian phản hồi email</span> 
                <select name="repmail">
                    <?php $i = 1; while($i<=30) { ?>
                        <option <?php if(!empty($user->repmail)) { if($user->repmail == $i) { echo 'selected="selected"';}}elseif($this->session->userdata('repmail') == $i){echo 'selected';} ?>value="<?php echo $i; ?>"><?php echo $i.' Giờ'; ?></option>
                    <?php $i++;} ?>
                </select>
				</p>
				<p class="row-b3"  style="color:#7DB520;font-size:15px;font-weight:bold">Tải ảnh đại diện</p>
                <p class="row-b3"<?php if($this->session->userdata('images') != '') { echo ' style="height:220px"';}?>>
                <span class="label2">Ảnh đại diện </span>
                <?php if($this->session->userdata('images') != '') { echo '<img src="'.base_url().'upload/avartars/'.$this->session->userdata('images').'" height="150px" width="120px" />';} else {echo '<p class="row-b3"><input type="file" name="avartar" /></p>';} ?></p>
                <input type="submit" value="Lưu và tiếp tục" class="bt-ok" />
            </form>
        </section>
</article>



<script>
    $(document).ready(function(){
        $('#province').change(function(){
           var province =$('#province').val();
           // Ajax Funtion chọn thành phố
           $.ajax({
                  type: "POST",
                  url: '<?php echo base_url(); ?>ajax/index',
                  data: {province : province },
                  success: success
                });
        });
        function success(data,status){
                    $('#district').html(data);
               };
    });
</script>